import {
  Controller,
  Get,
  Param,
  UseGuards,
} from '@nestjs/common';
import { FriendService } from './friend.service';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Friend } from 'src/entities/friend.entity';
import { User } from 'src/entities/user.entity';
import { HttpReslut } from 'src/common/result/http-reslut';
import { JwtAuthGuard } from 'src/common/jwt/JwtAuthGuard';

@ApiBearerAuth()
@UseGuards(new JwtAuthGuard())
@ApiTags('/好友模块')
@Controller('friend')
export class FriendController {
  constructor(private readonly friendService: FriendService) {}

  @ApiOperation({
    summary: '获取好友列表',
  })
  @Get(':userId')
  async findAll(@Param('userId') userId: string) {
    const friends: User[] = await this.friendService.findAll(userId);

    return new HttpReslut<User[]>(friends);
  }
}
